<template>
    <div>
      登录页面
      <!--<router-link :to="{name:'manage'}">登录</router-link>-->
      <el-button type="primary" size="mini" @click="handleSubmit">登录</el-button>
      <img :src="profilePath" alt="">
      {{nickname}}
    </div>
</template>

<script>
import loginData from '../api/index'
import MenuUtils from '../utils/MenuUtils'
let routers = []
export default {
  name: 'login',
  data () {
    return {
      profilePath: '',
      nickname: ''
    }
  },
  methods: {
    loginIn (data) {
      window.sessionStorage.setItem('user', JSON.stringify(data))
      MenuUtils(routers, data)
    },
    handleSubmit (ev) {
      let data = loginData.data
      this.loginIn(data)
      this.$router.addRoutes(routers)
      this.$router.push({ path: '/manage' })
    }
  },
  created () {
    this.$ajax.get('/admin/user/info').then(res => {
      console.log(res)
      if (res.data.success) {
        this.profilePath = res.data.data.userInfoVO.profilePhotoPath
        this.nickname = res.data.data.userInfoVO.nickname
      }
    })
  }
}
</script>

<style scoped>

</style>
